<?php
include("config.php");

?>
<!-- TODO:  make the tabs auto refresh so that they keep grabbing new feeds-->
<div class="toolbarTabs">
	<ul id="panelTabs" class="tab-menu">
	<?php
		$results = mysql_query("SELECT * FROM admin_settings");
		
		while ($row = mysql_fetch_array($results))
		{
			echo "<li id=\"panelTabs1Link\" class=\"selected\"><a>" . $row['rss_tab_1_title'] . "</a></li>";
			echo "<li id=\"panelTabs2Link\"><a>" . $row['rss_tab_2_title'] . "</a></li>";
		}
	?>
	</ul>
	<div class="clear"></div>
</div>

<script type="text/javascript">

var tabRefresh = function(){
	$('help-panel').fade('out');
	if ($('panelTabs1Link').hasClass('selected')) {
		MochaUI.updateContent({
			'element': $('help-panel'),
			'url': 'pages/getrss.php?q=tab1&nocache='+Math.random()
			});
	}
	else if ($('panelTabs2Link').hasClass('selected')) {
		MochaUI.updateContent({
			'element': $('help-panel'),
			'url': 'pages/getrss.php?q=tab2&nocache='+Math.random()
			});
	}
	
	//  Need to put a delay in before it fades in
	var fadeIn = function(){$('help-panel').fade('in');};
	fadeIn.delay(1000);
};
//  How often should the RSS tabs refresh in milliseconds
//TODO:  This should be added as a configurable option in the admin screen, and put in the global config
tabRefresh.periodical(60000);

MochaUI.initializeTabs('panelTabs');

$('panelTabs1Link').addEvent('click', function(e){
	MochaUI.updateContent({
		'element':  $('help-panel'),
		'url':       'pages/getrss.php?q=tab1&nocache='+Math.random()
	});
	
});

$('panelTabs2Link').addEvent('click', function(e){
	MochaUI.updateContent({
		'element': $('help-panel'),
		'url': 'pages/getrss.php?q=tab2&nocache='+Math.random()
	});
});

</script>
